package com.kai.mapper;

import com.kai.pojo.Emp;
import com.kai.pojo.EmpQueryParam;
import com.kai.pojo.LoginInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;

import java.util.List;

@Mapper
public interface EmpMapper {

//    //分页查询员工列表
//    @Select("select e.id, e.username, e.password, e.name, e.gender, e.phone, e.job, e.salary, e.image, e.entry_date, e.dept_id, e.create_time, e.update_time, d.name dept_Name " +
//            "from emp e left join dept d on e.dept_id = d.id order by e.update_time desc limit #{start},#{pageSize}")
//    List<Emp> page(Integer start, Integer pageSize);
//
//    //所有员工数
//    @Select("select count(*) from emp ")
//    long getTotal();

//    @Select("select e.id, e.username, e.password, e.name, e.gender, e.phone, e.job, e.salary, e.image, e.entry_date, e.dept_id, e.create_time, e.update_time, d.name dept_Name " +
//           "from emp e left join dept d on e.dept_id = d.id order by e.update_time desc")

    List<Emp> page(EmpQueryParam empQueryParam);

    @Options(useGeneratedKeys = true, keyProperty = "id") //插入的数据主键返回 到 emp.id中
    @Insert("insert into emp (username, name, gender, phone, job, salary, image, entry_date, dept_id, create_time, update_time)" +
            "VALUES (#{username}, #{name}, #{gender}, #{phone}, #{job}, #{salary}, #{image}, #{entryDate}, #{deptId}, #{createTime}, #{updateTime})")
    void add(Emp emp);

    void deleteByIds(List<Integer> ids);

    Emp getEmpInfoById(Integer id);

    void update(Emp emp);


    LoginInfo selectByUsernameAndPassword(Emp emp);
}



